package com.songhq.data.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.songhq.data.bean.FatherGrade;
import com.songhq.data.bean.PageVO;
import com.songhq.data.mapper.FatherGradeMapper;

@Service
public class FatherGradeService {

	@Autowired
	private FatherGradeMapper fatherGradeMapper;

	public PageVO listFatherGrades(FatherGrade fatherGrade) {
		//使用分页查询helper
		PageHelper.startPage(fatherGrade.getPageNumber(), fatherGrade.getPageSize());
		//执行查询
		List<FatherGrade> list = fatherGradeMapper.listFatherGrade(fatherGrade);
		//创建一个返回值对象
		PageVO<FatherGrade> pageBean = new PageVO<FatherGrade> ();
		pageBean.setList(list);
		//取分页结果
		PageInfo<FatherGrade> pageInfo = new PageInfo<>(list);
		//取总记录数
		long total = pageInfo.getTotal();
		pageBean.setCount(total);
		return pageBean;
	}

	public FatherGrade getOneFatherGrade(String fatherGradeId) {
		
		FatherGrade fatherGrade = fatherGradeMapper.getOneFatherGrade(fatherGradeId);
		return fatherGrade;
	}

	public void saveFatherGrade(FatherGrade fatherGrade) {
		
		fatherGradeMapper.insert(fatherGrade);
	}

	public void updateFatherGrade(FatherGrade fatherGrade) {
		
		fatherGradeMapper.updateFatherGrade(fatherGrade);
		
	}

	public void deleteFatherGrade(FatherGrade fatherGrade) {
		
		fatherGradeMapper.deleteFatherGrade(fatherGrade);
	}
	
	

}
